package com.asset.salesforce.service;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;

import com.asset.salesforce.dao.CalendarDaoImpl;
import com.asset.salesforce.model.Appointment;
import com.asset.salesforce.model.Calendar;
import com.asset.salesforce.model.Call;

@Service
@Transactional(readOnly=true)
public class CalendarService {

	@Autowired
	private CalendarDaoImpl calendarDaoImpl;
	
	@Transactional(readOnly=false)
	public void addEvent(Calendar calendar){
		calendarDaoImpl.add(calendar);
	}
	
	@Transactional(readOnly=true)
	public Calendar getEventById(Calendar calendar, Integer id){
		return calendarDaoImpl.getById(id, calendar);
	}
	
	@Transactional(readOnly=true)
	public List<Calendar> getAllEvents(Calendar calendar){
		return calendarDaoImpl.getAll(calendar);
	}
	
	@Transactional(readOnly=false)
	public void callEvent(Call call){
		calendarDaoImpl.callEvent(call);
	}

	@Transactional(readOnly=false)
	public void appointmentEvent(Appointment appointment){
		calendarDaoImpl.appointmentEvent(appointment);
	}
	
	@Transactional(readOnly=false)
	public List<Calendar> getAllEventsByEmplyoeeID(Integer id){
	return	calendarDaoImpl.getAllEventsByEmplyoeeID(id);
	}
	@Transactional(readOnly=true)
	public List<Calendar> getEventsbyEmployeeId(Integer empId){
		return calendarDaoImpl.getEventsbyEmployeeId(empId);
	}
	@Transactional(readOnly=true)
	public List<Calendar>getSelectedEventsbyEmployeeId(String eventType,Integer empId){
		return calendarDaoImpl.getSelectedEventsbyEmployeeId(eventType, empId);
	}
	public Calendar getEventByAppointmentId(Integer parentId) {
		return calendarDaoImpl.getEventByAppointmentId(parentId);
	}
	@Transactional(readOnly=true)
	public void getAppointmentEventsNo(HttpSession session, Model model){
		calendarDaoImpl.getAppointmentEventsNo(session, model);
	}
	public void getCallEventssNo(HttpSession session, Model model){
		calendarDaoImpl.getCallEventssNo(session, model);
	}
	public List<Calendar> getCallstByEmployeeID(Integer id){
		return	calendarDaoImpl.getCallstByEmployeeID(id);
	}
	public List<Calendar> getAppointmentEventsByEmployeeId(Integer id){
		return calendarDaoImpl.getAppointmentEventsByEmployeeId(id);
	}
	public List<Calendar> getEvents(Integer id){
		return calendarDaoImpl.getEvents(id);
	}
	@Transactional(readOnly=true)
	public List<Calendar> getEventByParentId(Integer parentId,String eventType) {
		return calendarDaoImpl.getEventByParentId(parentId, eventType);
	}
}
